package net.towee.client.com.repo.presenter;

import net.towee.client.com.repo.Repository;
import net.towee.client.com.repo.RepositoryExplorer;
import net.towee.client.com.repo.RepositoryShower;

import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.inject.Inject;

public class RepositoryPresenter implements Repository {

	public interface Display extends IsWidget {
		HasWidgets getExplorerContainer();
		
		HasWidgets getShowerContainer();
	}

	// Inject
	private final Display display;
	private final RepositoryShower shower;
	
	@Inject
	public RepositoryPresenter(Display display, RepositoryExplorer explorer, RepositoryShower shower){
		this.display = display;
		this.shower = shower;
		
		// Show repository components
		explorer.go( display.getExplorerContainer() );
		shower.go( display.getShowerContainer() );
	}
	
	@Override
	public void go(HasWidgets container) {
		// Show repository
		container.clear();
		container.add( display.asWidget() );
	}
}
